<?php
namespace BP\Sys;
require_once("BP/Tools/StringHelper.php");
require_once("net/sf/json/JSONArray.php");
require_once("net/sf/json/JSONObject.php");
class CCFormAPI {
	public static function GetAthInfos ($fk_mapdata, $pk) // [String fk_mapdata, String pk]
	{
		$num =DBAccess::RunSQL(((("SELECT COUNT(MYPK) FROM Sys_FrmAttachmentDB WHERE FK_MapData='" . $fk_mapdata) . "' AND RefPKVal=") . $pk));
		return (("附件(" . $num) . ")");
	}
	public static function CreatePublicNoNameCtrl ($fk_mapdata, $ctrlType, $no, $name, $x, $y) // [String fk_mapdata, String ctrlType, String no, String name, float x, float y]
	{
		$fe = NULL;
		switch ($ctrlType) {
			case "Dtl":
				CCFormAPI::CreateOrSaveDtl($fk_mapdata, $no, $name, $x, $y);
				break;
			case "AthMulti":
				CCFormAPI::CreateOrSaveAthMulti($fk_mapdata, $no, $name, $x, $y);
				break;
			case "AthSingle":
				CCFormAPI::CreateOrSaveAthSingle($fk_mapdata, $no, $name, $x, $y);
				break;
			case "AthImg":
				CCFormAPI::CreateOrSaveAthImg($fk_mapdata, $no, $name, $x, $y);
				break;
			case "Fieldset":
				$fe = FrmEle::constructor__();
				$fe->setMyPK((($fk_mapdata . "_") . $no));
				if (($fe->RetrieveFromDBSources() != 0))
				{
					throw new \RuntimeException((("@创建失败，已经有同名元素[" . $no) . "]的控�?."));
				}
				$fe->setFK_MapData($fk_mapdata);
				$fe->setEleType("Fieldset");
				$fe->setEleName($name);
				$fe->setEleID($no);
				$fe->setX($x);
				$fe->setY($y);
				$fe->Insert();
				break;
			case "iFrame":
				$mapFrame = MapFrame::constructor__();
				$mapFrame->setMyPK((($fk_mapdata . "_") . $no));
				if (($mapFrame->RetrieveFromDBSources() != 0))
				{
					throw new \RuntimeException((("@创建失败，已经有同名元素[" . $no) . "]的控�?."));
				}
				$mapFrame->setFK_MapData($fk_mapdata);
				$mapFrame->setEleType("iFrame");
				$mapFrame->setName($name);
				$mapFrame->setFrmID($no);
				$mapFrame->setURL("http://ccflow.org");
				$mapFrame->setX($x);
				$mapFrame->setY($y);
				$mapFrame->setW(400);
				$mapFrame->setH(600);
				$mapFrame->Insert();
				break;
			case "HandSiganture":
				$md = MapData::constructor__String($fk_mapdata);
				$md->CheckPTableSaveModel($no);
				$ma = MapAttr::constructor__();
				$ma->setFK_MapData($fk_mapdata);
				$ma->setKeyOfEn($no);
				$ma->setName($name);
				$ma->setMyDataType($DataType->AppString);
				$ma->setUIContralType($UIContralType->HandWriting);
				$ma->setX($x);
				$ma->setY($y);
				$groupField = GroupField::constructor__();
				$groupField->Retrieve(GroupFieldAttr::$FrmID, $fk_mapdata, GroupFieldAttr::$CtrlType, "");
				$ma->setGroupID($groupField->getOID());
				$ma->Insert();
				break;
			default:
				throw new \RuntimeException((("@没有判断的存储控�?:" . $ctrlType) . ",存储该控件前,�?要做判断."));
		}
	}
	public static function CreateOrSaveAthImg ($fk_mapdata, $no, $name, $x, $y) // [String fk_mapdata, String no, String name, float x, float y]
	{
		$ath = FrmImgAth::constructor__();
		$ath->setFK_MapData($fk_mapdata);
		$ath->setCtrlID($no);
		$ath->setMyPK((($fk_mapdata . "_") . $no));
		$ath->setX($x);
		$ath->setY($y);
		$ath->Insert();
	}
	public static function CreateOrSaveAthSingle ($fk_mapdata, $no, $name, $x, $y) // [String fk_mapdata, String no, String name, float x, float y]
	{
		$ath = FrmAttachment::constructor__();
		$ath->setFK_MapData($fk_mapdata);
		$ath->setNoOfObj($no);
		$ath->setMyPK((($ath->getFK_MapData() . "_") . $ath->getNoOfObj()));
		$ath->RetrieveFromDBSources();
		$ath->setUploadType(AttachmentUploadType::$Single);
		$ath->setName($name);
		$ath->setX($x);
		$ath->setY($y);
		$ath->Save();
	}
	public static function CreateOrSaveAthMulti ($fk_mapdata, $no, $name, $x, $y) // [String fk_mapdata, String no, String name, float x, float y]
	{
		$ath = FrmAttachment::constructor__();
		$ath->setFK_MapData($fk_mapdata);
		$ath->setNoOfObj($no);
		$ath->setMyPK((($ath->getFK_MapData() . "_") . $ath->getNoOfObj()));
		$i = $ath->RetrieveFromDBSources();
		if (($i == 0))
		{
			if (!SystemConfig::getCustomerNo()->equals("Factory5_mobile"))
			{
				$ath->setSaveTo((("/DataUser/UploadFile/" . $fk_mapdata) . "/"));
			}
			if (($fk_mapdata->contains("ND") ==  TRUE ))
			{
				$ath->setHisCtrlWay(AthCtrlWay::$WorkID);
			}
		}
		$ath->setUploadType(AttachmentUploadType::$Multi);
		$ath->setName($name);
		$ath->setX($x);
		$ath->setY($y);
		$ath->Save();
	}
	public static function CreateOrSaveDtl ($fk_mapdata, $dtlNo, $dtlName, $x, $y) // [String fk_mapdata, String dtlNo, String dtlName, float x, float y]
	{
		$dtl = MapDtl::constructor__();
		$dtl->setNo($dtlNo);
		if (($dtl->RetrieveFromDBSources() == 0))
		{
			if (($dtlName . NULL))
			{
				$dtlName = $dtlNo;
			}
			$md = MapData::constructor__String($fk_mapdata);
			$dtl->setPTableModel($md->getPTableModel());
			$dtl->setW(500);
		}
		$dtl->setX($x);
		$dtl->setY($y);
		$dtl->setName($dtlName);
		$dtl->setFK_MapData($fk_mapdata);
		$dtl->Save();
		$dtl->IntMapAttrs();
	}
	public static function SaveFieldSFTable_String_String_String_String_F_F ($fk_mapdata, $fieldName, $fieldDesc, $fk_SFTable, $x, $y) // [String fk_mapdata, String fieldName, String fieldDesc, String fk_SFTable, float x, float y]
	{
			/* match: String_String_String_String_F_F_I */
		CCFormAPI->SaveFieldSFTable_String_String_String_String_F_F_I($fk_mapdata, $fieldName, $fieldDesc, $fk_SFTable, $x, $y, 1);
	}
	public static function SaveFieldSFTable_String_String_String_String_F_F_I ($fk_mapdata, $fieldName, $fieldDesc, $fk_SFTable, $x, $y, $colSpan) // [String fk_mapdata, String fieldName, String fieldDesc, String fk_SFTable, float x, float y, int colSpan]
	{
		$md = MapData::constructor__();
		$md->setNo($fk_mapdata);
		if (($md->RetrieveFromDBSources() == 1))
		{
			$md->CheckPTableSaveModel($fieldName);
		}
		$sf = SFTable::constructor__String($fk_SFTable);
		if (($DataType->IsNullOrEmpty($fieldDesc) ==  TRUE ))
		{
			$fieldDesc = $sf->getName();
		}
		$attr = MapAttr::constructor__();
		$attr->setMyPK((($fk_mapdata . "_") . $fieldName));
		$attr->RetrieveFromDBSources();
		$attr->setFK_MapData($fk_mapdata);
		$attr->setKeyOfEn($fieldName);
		$attr->setName($fieldDesc);
		$attr->setMyDataType(DataType->AppString);
		$attr->setUIContralType($BP->En->UIContralType->DDL);
		$attr->setUIBindKey($fk_SFTable);
		$attr->setX($x);
		$attr->setY($y);
		switch ($sf->getSrcType()) {
			case $CreateTable:
			case $TableOrView:
			case $BPClass:
				$attr->setLGType($FieldTypeS->FK);
				break;
			case $SQL:
			default:
				$attr->setLGType($FieldTypeS->Normal);
				break;
		}
		$groupField = GroupField::constructor__();
		$groupField->Retrieve(GroupFieldAttr::$FrmID, $fk_mapdata, GroupFieldAttr::$CtrlType, "");
		$attr->setGroupID($groupField->getOID());
		$attr->Save();
		if (($attr->getLGType() == $FieldTypeS->Normal))
		{
			$attrH = MapAttr::constructor__();
			$attrH->Copy($attr);
			$attrH->setKeyOfEn(($attr->getKeyOfEn() . "T"));
			$attrH->setName($attr->getName());
			$attrH->setUIContralType($BP->En->UIContralType->TB);
			$attrH->setMinLen(0);
			$attrH->setMaxLen(500);
			$attrH->setMyDataType(DataType->AppString);
			$attrH->setUIVisible( FALSE );
			$attrH->setUIIsEnable( FALSE );
			$attrH->setMyPK((($attrH->getFK_MapData() . "_") . $attrH->getKeyOfEn()));
			$attrH->Save();
		}
	}
	public static function SaveFieldEnum_String_String_String_String_UIContralType_F_F ($fk_mapdata, $fieldName, $fieldDesc, $enumKey, $ctrlType, $x, $y) // [String fk_mapdata, String fieldName, String fieldDesc, String enumKey, UIContralType ctrlType, float x, float y]
	{
			/* match: String_String_String_String_UIContralType_F_F_I */
		CCFormAPI->SaveFieldEnum_String_String_String_String_UIContralType_F_F_I($fk_mapdata, $fieldName, $fieldDesc, $enumKey, $ctrlType, $x, $y, 1);
	}
	public static function SaveFieldEnum_String_String_String_String_UIContralType_F_F_I ($fk_mapdata, $fieldName, $fieldDesc, $enumKey, $ctrlType, $x, $y, $colSpan) // [String fk_mapdata, String fieldName, String fieldDesc, String enumKey, UIContralType ctrlType, float x, float y, int colSpan]
	{
		$ma = MapAttr::constructor__();
		$ma->setFK_MapData($fk_mapdata);
		$ma->setKeyOfEn($fieldName);
		$ma->setMyPK((($ma->getFK_MapData() . "_") . $ma->getKeyOfEn()));
		$ma->RetrieveFromDBSources();
		$ma->setName($fieldDesc);
		$ma->setMyDataType($DataType->AppInt);
		$ma->setX($x);
		$ma->setY($y);
		$ma->setUIIsEnable( TRUE );
		$ma->setLGType($FieldTypeS->Enum);
		$ma->setUIContralType($ctrlType);
		$ma->setUIBindKey($enumKey);
		if (($ma->getUIContralType() == $UIContralType->RadioBtn))
		{
			$ses = SysEnums::constructor__String($ma->getUIBindKey());
			$idx = 0;
			foreach ($ses->ToJavaList() as $item) 			{
				++$idx;
				$rb = FrmRB::constructor__();
				$rb->setFK_MapData($ma->getFK_MapData());
				$rb->setKeyOfEn($ma->getKeyOfEn());
				$rb->setIntKey($item->getIntKey());
				$rb->setMyPK((((($rb->getFK_MapData() . "_") . $rb->getKeyOfEn()) . "_") . $rb->getIntKey()));
				$rb->RetrieveFromDBSources();
				$rb->setEnumKey($ma->getUIBindKey());
				$rb->setLab($item->getLab());
				$rb->setX($ma->getX());
				$rb->setY(($ma->getY() + ($idx * 30)));
				$rb->Save();
			}
		}
		$groupField = GroupField::constructor__();
		$groupField->Retrieve(GroupFieldAttr::$FrmID, $fk_mapdata, GroupFieldAttr::$CtrlType, "");
		$ma->setGroupID($groupField->getOID());
		$ma->Save();
	}
	public static function NewImage ($frmID, $keyOfEn, $name, $x, $y) // [String frmID, String keyOfEn, String name, float x, float y]
	{
		$img = FrmImg::constructor__();
		$img->setMyPK($keyOfEn);
		$img->setFK_MapData($frmID);
		$img->setName($name);
		$img->setIsEdit(1);
		$img->setHisImgAppType(ImgAppType::$Img);
		$img->setX($x);
		$img->setY($y);
		$img->Insert();
	}
	public static function NewField_String_String_String_I_F_F ($frmID, $field, $fieldDesc, $mydataType, $x, $y) // [String frmID, String field, String fieldDesc, int mydataType, float x, float y]
	{
			/* match: String_String_String_I_F_F_I */
		CCFormAPI->NewField_String_String_String_I_F_F_I($frmID, $field, $fieldDesc, $mydataType, $x, $y, 1);
	}
	public static function NewField_String_String_String_I_F_F_I ($frmID, $field, $fieldDesc, $mydataType, $x, $y, $colSpan) // [String frmID, String field, String fieldDesc, int mydataType, float x, float y, int colSpan]
	{
		$md = MapData::constructor__String($frmID);
		$md->CheckPTableSaveModel($field);
		$ma = MapAttr::constructor__();
		$ma->setFK_MapData($frmID);
		$ma->setKeyOfEn($field);
		$ma->setName($fieldDesc);
		$ma->setMyDataType($mydataType);
		$ma->setX($x);
		$ma->setY($y);
		$groupField = GroupField::constructor__();
		$groupField->Retrieve(GroupFieldAttr::$FrmID, $frmID, GroupFieldAttr::$CtrlType, "");
		$ma->setGroupID($groupField->getOID());
		$ma->Insert();
	}
	public static function NewEnumField_String_String_String_String_UIContralType_F_F ($fk_mapdata, $field, $fieldDesc, $enumKey, $ctrlType, $x, $y) // [String fk_mapdata, String field, String fieldDesc, String enumKey, UIContralType ctrlType, float x, float y]
	{
			/* match: String_String_String_String_UIContralType_F_F_I */
		CCFormAPI->NewEnumField_String_String_String_String_UIContralType_F_F_I($fk_mapdata, $field, $fieldDesc, $enumKey, $ctrlType, $x, $y, 1);
	}
	public static function NewEnumField_String_String_String_String_UIContralType_F_F_I ($fk_mapdata, $field, $fieldDesc, $enumKey, $ctrlType, $x, $y, $colSpan) // [String fk_mapdata, String field, String fieldDesc, String enumKey, UIContralType ctrlType, float x, float y, int colSpan]
	{
		$md = MapData::constructor__String($fk_mapdata);
		$md->CheckPTableSaveModel($field);
		$ma = MapAttr::constructor__();
		$ma->setFK_MapData($fk_mapdata);
		$ma->setKeyOfEn($field);
		$ma->setName($fieldDesc);
		$ma->setMyDataType($DataType->AppInt);
		$ma->setX($x);
		$ma->setY($y);
		$ma->setUIIsEnable( TRUE );
		$ma->setLGType($FieldTypeS->Enum);
		$ma->setUIContralType($ctrlType);
		$ma->setUIBindKey($enumKey);
		$groupField = GroupField::constructor__();
		$groupField->Retrieve(GroupFieldAttr::$FrmID, $fk_mapdata, GroupFieldAttr::$CtrlType, "");
		$ma->setGroupID($groupField->getOID());
		$ma->Insert();
		if (($ma->getUIContralType() != $UIContralType->RadioBtn))
		{
			return ;
		}
		DBAccess::RunSQL((((("DELETE FROM Sys_FrmRB WHERE KeyOfEn='" . $ma->getKeyOfEn()) . "' AND FK_MapData='") . $ma->getFK_MapData()) . "'"));
		$ses = SysEnums::constructor__String($ma->getUIBindKey());
		$idx = 0;
		foreach ($ses->ToJavaList() as $item) 		{
			++$idx;
			$rb = FrmRB::constructor__();
			$rb->setFK_MapData($ma->getFK_MapData());
			$rb->setKeyOfEn($ma->getKeyOfEn());
			$rb->setEnumKey($ma->getUIBindKey());
			$rb->setLab($item->getLab());
			$rb->setIntKey($item->getIntKey());
			$rb->setX($ma->getX());
			$rb->setY(($ma->getY() + ($idx * 30)));
			$rb->Insert();
		}
	}
	public static function NewCheckGroup ($frmID, $gKey, $gName) // [String frmID, String gKey, String gName]
	{
		$attrN = MapAttr::constructor__();
		$i = $attrN->Retrieve(MapAttrAttr::$FK_MapData, $frmID, MapAttrAttr::$KeyOfEn, ($gKey . "_Note"));
		$i += $attrN->Retrieve(MapAttrAttr::$FK_MapData, $frmID, MapAttrAttr::$KeyOfEn, ($gKey . "_Checker"));
		$i += $attrN->Retrieve(MapAttrAttr::$FK_MapData, $frmID, MapAttrAttr::$KeyOfEn, ($gKey . "_RDT"));
		if (($i > 0))
		{
			return (("err@前缀已经使用�?" . $gKey) . " �? 请确认您是否增加了这个审核分组或者，请您更换其他的前�?�?");
		}
		$gf = GroupField::constructor__();
		$gf->setLab($gName);
		$gf->setFrmID($frmID);
		$gf->Insert();
		$attrN = MapAttr::constructor__();
		$attrN->setFK_MapData($frmID);
		$attrN->setKeyOfEn(($gKey . "_Note"));
		$attrN->setName("审核意见");
		$attrN->setMyDataType($DataType->AppString);
		$attrN->setUIContralType($UIContralType->TB);
		$attrN->setUIIsEnable( TRUE );
		$attrN->setUIIsLine( TRUE );
		$attrN->setMaxLen(4000);
		$attrN->setGroupID($gf->getOID());
		$attrN->setUIHeight((23 * 3));
		$attrN->setIdx(1);
		$attrN->Insert();
		$attrN = MapAttr::constructor__();
		$attrN->setFK_MapData($frmID);
		$attrN->setKeyOfEn(($gKey . "_Checker"));
		$attrN->setName("审核�?");
		$attrN->setMyDataType($DataType->AppString);
		$attrN->setUIContralType($UIContralType->TB);
		$attrN->setMaxLen(50);
		$attrN->setMinLen(0);
		$attrN->setUIIsEnable( TRUE );
		$attrN->setUIIsLine( FALSE );
		$attrN->setDefVal("@WebUser.getName()");
		$attrN->setUIIsEnable( FALSE );
		$attrN->setGroupID($gf->getOID());
		$attrN->setIsSigan( TRUE );
		$attrN->setIdx(2);
		$attrN->Insert();
		$attrN = MapAttr::constructor__();
		$attrN->setFK_MapData($frmID);
		$attrN->setKeyOfEn(($gKey . "_RDT"));
		$attrN->setName("审核日期");
		$attrN->setMyDataType($DataType->AppDateTime);
		$attrN->setUIContralType($UIContralType->TB);
		$attrN->setUIIsEnable( TRUE );
		$attrN->setUIIsLine( FALSE );
		$attrN->setDefVal("@RDT");
		$attrN->setUIIsEnable( FALSE );
		$attrN->setGroupID($gf->getOID());
		$attrN->setIdx(3);
		$attrN->Insert();
		$frmID = $frmID->replace("ND", "");
		$nodeid = 0;
		try 
		{
			$nodeid = $Integer->parseInt($frmID);
		}
		catch (\Exception $e)
		{
			return "error:只能节点表单才可以使用审核分组组件�??";
		}
		return NULL;
	}
	public static function CreateCheckGroup ($frmID, $groupName, $prx) // [String frmID, String groupName, String prx]
	{
		$gf = GroupField::constructor__();
		$gf->setLab($groupName);
		$gf->setFrmID($frmID);
		$i = $gf->Retrieve(GroupFieldAttr::$Lab, $groupName, GroupFieldAttr::$FrmID, $frmID);
		if (($i == 0))
		{
			$gf->Insert();
		}
		$attr = MapAttr::constructor__();
		$attr->setFK_MapData($frmID);
		$attr->setKeyOfEn(($prx . "_Note"));
		$attr->setName("审核意见");
		$attr->setMyDataType($DataType->AppString);
		$attr->setUIContralType($UIContralType->TB);
		$attr->setUIIsEnable( TRUE );
		$attr->setUIIsLine( TRUE );
		$attr->setMaxLen(4000);
		$attr->SetValByKey(MapAttrAttr::$ColSpan, 4);
		$attr->setGroupID($gf->getOID());
		$attr->setUIHeight((23 * 3));
		$attr->setIdx(1);
		$attr->Insert();
		$attr->Update("Idx", 1);
		$attr = MapAttr::constructor__();
		$attr->setFK_MapData($frmID);
		$attr->setKeyOfEn(($prx . "_Checker"));
		$attr->setName("审核�?");
		$attr->setMyDataType($DataType->AppString);
		$attr->setUIContralType($UIContralType->TB);
		$attr->setMaxLen(50);
		$attr->setMinLen(0);
		$attr->setUIIsEnable( TRUE );
		$attr->setUIIsLine( FALSE );
		$attr->setDefVal("@WebUser.getNo()");
		$attr->setUIIsEnable( FALSE );
		$attr->setGroupID($gf->getOID());
		$attr->setIsSigan( TRUE );
		$attr->setIdx(2);
		$attr->Insert();
		$attr->Update("Idx", 2);
		$attr = MapAttr::constructor__();
		$attr->setFK_MapData($frmID);
		$attr->setKeyOfEn(($prx . "_RDT"));
		$attr->setName("审核日期");
		$attr->setMyDataType($DataType->AppDateTime);
		$attr->setUIContralType($UIContralType->TB);
		$attr->setUIIsEnable( TRUE );
		$attr->setUIIsLine( FALSE );
		$attr->setDefVal("@RDT");
		$attr->setUIIsEnable( FALSE );
		$attr->setGroupID($gf->getOID());
		$attr->setIdx(3);
		$attr->Insert();
		$attr->Update("Idx", 3);
	}
	public static function CreateFrm_String_String_String ($frmID, $frmName, $frmTreeID) // [String frmID, String frmName, String frmTreeID]
	{
			/* match: String_String_String_FrmType */
		CCFormAPI->CreateFrm_String_String_String_FrmType($frmID, $frmName, $frmTreeID, FrmType::$FreeFrm);
	}
	public static function CreateFrm_String_String_String_FrmType ($frmID, $frmName, $frmTreeID, $frmType) // [String frmID, String frmName, String frmTreeID, FrmType frmType]
	{
		$md = MapData::constructor__();
		$md->setNo($frmID);
		if (($md->getIsExits() ==  TRUE ))
		{
			throw new \RuntimeException((("@表单ID�?:" . $frmID) . " 已经存在."));
		}
		$md->setName($frmName);
		$md->setHisFrmType($frmType);
		$md->Insert();
	}
	public static function RepareCCForm ($frmID) // [String frmID]
	{
		$attr = MapAttr::constructor__();
		if (($attr->IsExit(MapAttrAttr::$KeyOfEn, "OID", MapAttrAttr::$FK_MapData, $frmID) ==  FALSE ))
		{
			$attr->setFK_MapData($frmID);
			$attr->setKeyOfEn("OID");
			$attr->setName("主键");
			$attr->setMyDataType(DataType->AppInt);
			$attr->setUIContralType($UIContralType->TB);
			$attr->setLGType($FieldTypeS->Normal);
			$attr->setUIVisible( FALSE );
			$attr->setUIIsEnable( FALSE );
			$attr->setDefVal("0");
			$attr->setHisEditType($BP->En->EditType->Readonly);
			$attr->Insert();
		}
	}
	public static function SaveFrm_String_String ($fk_mapdata, $jsonStrOfH5Frm) // [String fk_mapdata, String jsonStrOfH5Frm]
	{
		$jd = $JSONObject->fromObject($jsonStrOfH5Frm);
		if ($jd->isNullObject())
		{
			throw new \RuntimeException("error:表单格式不正确，保存失败�?");
		}
		$form_MapData = $jd->getJSONObject("c");
		$mapData = MapData::constructor__String($fk_mapdata);
		$mapData->setFrmW($Float->parseFloat($form_MapData->optString("width")));
		$mapData->setFrmH($Float->parseFloat($form_MapData->optString("height")));
		$mapData->setDesignerTool("Html5");
		$mapData->Update();
		CCFormAPI->SaveFrm_String_JSONObject($fk_mapdata, $jd);
		CashEntity::getDCash()->clear();
	}
	protected static function SaveFrm_String_JSONObject ($fk_mapdata, $formData) // [String fk_mapdata, JSONObject formData]
	{
		$labelPKs = "@";
		$labs = FrmLabs::constructor__();
		$labs->Retrieve(FrmLabAttr::$FK_MapData, $fk_mapdata);
		foreach ($labs->ToJavaList() as $item) 		{
			$labelPKs += ($item->getMyPK() . "@");
		}
		$linkPKs = "@";
		$links = FrmLinks::constructor__();
		$links->Retrieve(FrmLabAttr::$FK_MapData, $fk_mapdata);
		foreach ($links->ToJavaList() as $item) 		{
			$linkPKs += ($item->getMyPK() . "@");
		}
		$btnsPKs = "@";
		$btns = FrmBtns::constructor__();
		$btns->Retrieve(FrmLabAttr::$FK_MapData, $fk_mapdata);
		foreach ($btns->ToJavaList() as $item) 		{
			$btnsPKs += ($item->getMyPK() . "@");
		}
		$imgPKs = "@";
		$imgs = FrmImgs::constructor__();
		$imgs->Retrieve(FrmLabAttr::$FK_MapData, $fk_mapdata);
		foreach ($imgs->ToJavaList() as $item) 		{
			$imgPKs += ($item->getMyPK() . "@");
		}
		$attrPKs = "@";
		$attrs = MapAttrs::constructor__();
		$attrs->Retrieve(MapDtlAttr::$FK_MapData, $fk_mapdata);
		foreach ($attrs->ToJavaList() as $item) 		{
			if ($item->getKeyOfEn()->equals("OID"))
			{
				continue;
			}
			if (($item->getUIVisible() ==  FALSE ))
			{
				continue;
			}
			$attrPKs += ($item->getKeyOfEn() . "@");
		}
		$attrPKs += "@";
		$dtlPKs = "@";
		$dtls = MapDtls::constructor__();
		$dtls->Retrieve(MapDtlAttr::$FK_MapData, $fk_mapdata);
		foreach ($dtls->ToJavaList() as $item) 		{
			$dtlPKs += ($item->getNo() . "@");
		}
		$dtlPKs += "@";
		$athMultis = "@";
		$aths = FrmAttachments::constructor__();
		$aths->Retrieve(MapDtlAttr::$FK_MapData, $fk_mapdata);
		foreach ($aths->ToJavaList() as $item) 		{
			$athMultis += ($item->getNoOfObj() . "@");
		}
		$athMultis += "@";
		$athImgs = "@";
		$fias = FrmImgAths::constructor__();
		$fias->Retrieve(MapDtlAttr::$FK_MapData, $fk_mapdata);
		foreach ($fias->ToJavaList() as $item) 		{
			$athImgs += ($item->getCtrlID() . "@");
		}
		$athImgs += "@";
		$eleIDs = "@";
		$feles = FrmEles::constructor__();
		$feles->Retrieve(MapDtlAttr::$FK_MapData, $fk_mapdata);
		foreach ($feles->ToJavaList() as $item) 		{
			$eleIDs += ($item->getEleID() . "@");
		}
		$eleIDs += "@";
		$frameIDs = "@";
		$frames = MapFrames::constructor__();
		$frames->Retrieve(MapDtlAttr::$FK_MapData, $fk_mapdata);
		foreach ($frames->ToJavaList() as $item) 		{
			$frameIDs += ($item->getMyPK() . "@");
		}
		$frameIDs += "@";
		$form_Lines = $formData->getJSONObject("m")->getJSONArray("connectors");
		CCFormParse->SaveLine($fk_mapdata, $form_Lines);
		$form_Controls = $formData->getJSONObject("s")->getJSONArray("figures");
		if ((($form_Controls->isArray() ==  FALSE ) || ($form_Controls->size() == 0)))
		{
			$delSqls = "";
			$delSqls += (("@DELETE FROM Sys_MapAttr WHERE FK_MapData='" . $fk_mapdata) . "' AND KeyOfEn NOT IN ('OID')");
			$delSqls += (("@DELETE FROM Sys_FrmRB WHERE FK_MapData='" . $fk_mapdata) . "'");
			$delSqls += (("@DELETE FROM Sys_MapDtl WHERE FK_MapData='" . $fk_mapdata) . "'");
			$delSqls += (("@DELETE FROM Sys_FrmBtn WHERE FK_MapData='" . $fk_mapdata) . "'");
			$delSqls += (("@DELETE FROM Sys_FrmLine WHERE FK_MapData='" . $fk_mapdata) . "'");
			$delSqls += (("@DELETE FROM Sys_FrmLab WHERE FK_MapData='" . $fk_mapdata) . "'");
			$delSqls += (("@DELETE FROM Sys_FrmLink WHERE FK_MapData='" . $fk_mapdata) . "'");
			$delSqls += (("@DELETE FROM Sys_FrmImg WHERE FK_MapData='" . $fk_mapdata) . "'");
			$delSqls += (("@DELETE FROM Sys_FrmAttachment WHERE FK_MapData='" . $fk_mapdata) . "'");
			$delSqls += (("@DELETE FROM Sys_FrmEle WHERE FK_MapData='" . $fk_mapdata) . "'");
			$delSqls += (("@DELETE FROM Sys_FrmImgAth WHERE FK_MapData='" . $fk_mapdata) . "'");
			$delSqls += (("@DELETE FROM Sys_MapFrame WHERE FK_MapData='" . $fk_mapdata) . "'");
			DBAccess->RunSQLs($delSqls);
			return ;
		}
		$flowEle = "";
		$sqls = "";
		$nodeIDStr = $fk_mapdata->replace("ND", "");
		$nodeID = 0;
		if ((DataType->IsNumStr($nodeIDStr) ==  TRUE ))
		{
			$nodeID = $Integer->parseInt($nodeIDStr);
		}
		$flowCtrls = "";
		for ($idx = 0$jControl = $form_Controls->size(); ($idx < $jControl); ++$idx) 
		{
			$control = $form_Controls->getJSONObject($idx);
			if ((($control == NULL) || ($control->get("CCForm_Shape") == NULL)))
			{
				continue;
			}
			$shape = $control->get("CCForm_Shape");
			if (($control->optString("CCForm_MyPK") == NULL))
			{
				continue;
			}
			if (($control->get("CCForm_MyPK") == NULL))
			{
				continue;
			}
			$ctrlID = $control->get("CCForm_MyPK");
			$properties = $control->getJSONArray("properties");
			switch ($shape) {
				case "Label":
					if (($ctrlID->indexOf("RB_") == 0))
					{
						$shape = "RadioButtonItem";
					}
					else
					{
						CCFormParse->SaveLabel($fk_mapdata, $control, $properties, $labelPKs, $ctrlID);
						$labelPKs = $labelPKs->replace(($ctrlID . "@"), "@");
					}
					continue;
				case "Button":
					CCFormParse->SaveButton($fk_mapdata, $control, $properties, $btnsPKs, $ctrlID);
					$btnsPKs = $btnsPKs->replace(($ctrlID . "@"), "@");
					continue;
				case "HyperLink":
					CCFormParse->SaveHyperLink($fk_mapdata, $control, $properties, $linkPKs, $ctrlID);
					$linkPKs = $linkPKs->replace(($ctrlID . "@"), "@");
					continue;
				case "Image":
					CCFormParse->SaveImage($fk_mapdata, $control, $properties, $imgPKs, $ctrlID);
					$imgPKs = $imgPKs->replace(($ctrlID . "@"), "@");
					continue;
				default:
					break;
			}
			if (((($shape->contains("TextBox") ==  TRUE ) || ($shape->contains("DropDownList") ==  TRUE )) || FrmEle::$HandSiganture->equals($shape)))
			{
				CCFormParse->SaveMapAttr($fk_mapdata, $ctrlID, $shape, $control, $properties, $attrPKs);
				$attrPKs = $attrPKs->replace((("@" . $ctrlID) . "@"), "@");
				continue;
			}
			$style = $control->getJSONObject("style");
			$vector = $style->getJSONArray("gradientBounds");
			$x = $Float->parseFloat($String->valueOf($vector->get(0)));
			$y = $Float->parseFloat($String->valueOf($vector->get(1)));
			$maxX = $Float->parseFloat($String->valueOf($vector->get(2)));
			$maxY = $Float->parseFloat($String->valueOf($vector->get(3)));
			$width = ($maxX - $x);
			$height = ($maxY - $y);
			if ($shape->equals("Dtl"))
			{
				CCFormParse->SaveDtl($fk_mapdata, $ctrlID, $x, $y, $height, $width);
				$dtlPKs = $dtlPKs->replace((("@" . $ctrlID) . "@"), "@");
				continue;
			}
			if (($shape->equals("AthMulti") || $shape->equals("AthSingle")))
			{
				CCFormParse->SaveAthMulti($fk_mapdata, $ctrlID, $x, $y, $height, $width);
				$athMultis = $athMultis->replace((("@" . $ctrlID) . "@"), "@");
				continue;
			}
			if ($shape->equals("AthImg"))
			{
				CCFormParse->SaveAthImg($fk_mapdata, $ctrlID, $x, $y, $height, $width);
				$athImgs = $athImgs->replace((("@" . $ctrlID) . "@"), "@");
				continue;
			}
			if (($shape->equals("Fieldset") || FrmEle::$Fieldset->equals($shape)))
			{
				CCFormParse->SaveFrmEle($fk_mapdata, $shape, $ctrlID, $x, $y, $height, $width);
				$eleIDs = $eleIDs->replace((("@" . $ctrlID) . "@"), "@");
				continue;
			}
			if ($shape->equals("iFrame"))
			{
				CCFormParse->SaveMapFrame($fk_mapdata, $shape, $ctrlID, $x, $y, $height, $width);
				$frameIDs = $frameIDs->replace((("@" . $ctrlID) . "@"), "@");
				continue;
			}
			if ($shape->equals("RadioButton"))
			{
				if (($ctrlID->contains("=") ==  TRUE ))
				{
					continue;
				}
				if (($ctrlID->contains("RB_") ==  TRUE ))
				{
					$ctrlID = $ctrlID->substring(3);
				}
				$str = CCFormParse->SaveFrmRadioButton($fk_mapdata, $ctrlID, $x, $y);
				if (($str . NULL))
				{
					continue;
				}
				$attrPKs = $attrPKs->replace((("@" . $str) . "@"), "@");
				continue;
			}
			if ($shape->equals("RadioButton"))
			{
				continue;
			}
			if (((($shape->equals("FlowChart") || $shape->equals("FrmCheck")) || $shape->equals("SubFlowDtl")) || $shape->equals("ThreadDtl")))
			{
				if (($flowCtrls->contains($shape) ==  FALSE ))
				{
					$flowCtrls += ((((((((("@Ctrl=" . $shape) . ",X=") . $x) . ",Y=") . $y) . ",H=") . $height) . ",W=") . $width);
				}
			}
			if (($nodeID != 0))
			{
				$sqls = "";
				switch ($shape) {
					case "FlowChart":
						if (DBAccess->RunSQLReturnString(("SELECT FrmTrackSta FROM WF_Node WHERE NodeID=" . $nodeID))->equals("0"))
						{
							$sqls += ((((((((("@UPDATE WF_Node SET FrmTrackSta=1,FrmTrack_X=" . $x) . ",FrmTrack_Y=") . $y) . ",FrmTrack_H=") . $height) . ", FrmTrack_W=") . $width) . " WHERE NodeID=") . $nodeIDStr);
						}
						else
						{
							$sqls += ((((((((("@UPDATE WF_Node SET FrmTrack_X=" . $x) . ",FrmTrack_Y=") . $y) . ",FrmTrack_H=") . $height) . ", FrmTrack_W=") . $width) . " WHERE NodeID=") . $nodeIDStr);
						}
						$flowEle += ($shape . ",");
						continue;
					case "FrmCheck":
						if (DBAccess->RunSQLReturnString(("SELECT FWCSta FROM WF_Node WHERE NodeID=" . $nodeID))->equals("0"))
						{
							$sqls += ((((((((("@UPDATE WF_Node SET FWCSta=1,FWC_X=" . $x) . ",FWC_Y=") . $y) . ",FWC_H=") . $height) . ", FWC_W=") . $width) . " WHERE NodeID=") . $nodeIDStr);
						}
						else
						{
							$sqls += ((((((((("@UPDATE WF_Node SET FWC_X=" . $x) . ",FWC_Y=") . $y) . ",FWC_H=") . $height) . ", FWC_W=") . $width) . " WHERE NodeID=") . $nodeIDStr);
						}
						$flowEle += ($shape . ",");
						continue;
					case "SubFlowDtl":
						if (DBAccess->RunSQLReturnString(("SELECT SFSta FROM WF_Node WHERE NodeID=" . $nodeID))->equals("0"))
						{
							$sqls += ((((((((("@UPDATE WF_Node SET SFSta=1,SF_X=" . $x) . ",SF_Y=") . $y) . ",SF_H=") . $height) . ", SF_W=") . $width) . " WHERE NodeID=") . $nodeIDStr);
						}
						else
						{
							$sqls += ((((((((("@UPDATE WF_Node SET SF_X=" . $x) . ",SF_Y=") . $y) . ",SF_H=") . $height) . ", SF_W=") . $width) . " WHERE NodeID=") . $nodeIDStr);
						}
						$flowEle += ($shape . ",");
						continue;
					case "ThreadDtl":
						if (DBAccess->RunSQLReturnString(("SELECT FrmThreadSta FROM WF_Node WHERE NodeID=" . $nodeID))->equals("0"))
						{
							$sqls += ((((((((("@UPDATE WF_Node SET FrmThreadSta=1,FrmThread_X=" . $x) . ",FrmThread_Y=") . $y) . ",FrmThread_H=") . $height) . ",FrmThread_W=") . $width) . " WHERE NodeID=") . $nodeIDStr);
						}
						else
						{
							$sqls += ((((((((("@UPDATE WF_Node SET FrmThread_X=" . $x) . ",FrmThread_Y=") . $y) . ",FrmThread_H=") . $height) . ", FrmThread_W=") . $width) . " WHERE NodeID=") . $nodeIDStr);
						}
						$flowEle += ($shape . ",");
						continue;
					case "FrmTransferCustom":
						if (DBAccess->RunSQLReturnString(("SELECT FTCSta FROM WF_Node WHERE NodeID=" . $nodeID))->equals("0"))
						{
							$sqls += ((((((((("@UPDATE WF_Node SET FTCSta=1,FTC_X=" . $x) . ",FTC_Y=") . $y) . ",FTC_H=") . $height) . ",FTC_W=") . $width) . " WHERE NodeID=") . $nodeIDStr);
						}
						else
						{
							$sqls += ((((((((("@UPDATE WF_Node SET FTC_X=" . $x) . ",FTC_Y=") . $y) . ",FrmThread_H=") . $height) . ",FTC_W=") . $width) . " WHERE NodeID=") . $nodeIDStr);
						}
						$flowEle += ($shape . ",");
						continue;
					default:
						break;
				}
			}
			if (((($shape->equals("FlowChart") || $shape->equals("FrmCheck")) || $shape->equals("SubFlowDtl")) || $shape->equals("ThreadDtl")))
			{
				continue;
			}
			throw new \RuntimeException(("@没有判断的ccform保存控件的类�?:shape = " . $shape));
		}
		if (($nodeID != 0))
		{
			if (($flowEle->contains("FlowChart") ==  FALSE ))
			{
				$sqls += ("@UPDATE WF_Node SET FrmTrackSta=0 WHERE NodeID=" . $nodeID);
			}
			if (($flowEle->contains("FrmCheck") ==  FALSE ))
			{
				$sqls += ("@UPDATE WF_Node SET FWCSta=0 WHERE NodeID=" . $nodeID);
			}
			if (($flowEle->contains("SubFlowDtl") ==  FALSE ))
			{
				$sqls += ("@UPDATE WF_Node SET SFSta=0 WHERE NodeID=" . $nodeID);
			}
			if (($flowEle->contains("ThreadDtl") ==  FALSE ))
			{
				$sqls += ("@UPDATE WF_Node SET FrmThreadSta=0 WHERE NodeID=" . $nodeID);
			}
			if (($flowEle->contains("FrmTransferCustom") ==  FALSE ))
			{
				$sqls += ("@UPDATE WF_Node SET FTCSta=0 WHERE NodeID=" . $nodeID);
			}
		}
		if (!$sqls->equals(""))
		{
			DBAccess->RunSQLs($sqls);
			$sqls = "";
		}
		DBAccess::RunSQL((((("UPDATE Sys_MapData SET FlowCtrls='" . $flowCtrls) . "' WHERE No='") . $fk_mapdata) . "'"));
		$pks = $labelPKs->split("[@]", -1);
		$sqls = "";
		foreach ($pks as $pk) 		{
			if ($DataType->IsNullOrEmpty($pk))
			{
				continue;
			}
			$sqls += (("@DELETE FROM Sys_FrmLab WHERE MyPK='" . $pk) . "'");
		}
		$pks = $btnsPKs->split("[@]", -1);
		foreach ($pks as $pk) 		{
			if ($DataType->IsNullOrEmpty($pk))
			{
				continue;
			}
			$sqls += (("@DELETE FROM Sys_FrmBtn WHERE MyPK='" . $pk) . "'");
		}
		$pks = $linkPKs->split("[@]", -1);
		foreach ($pks as $pk) 		{
			if ($DataType->IsNullOrEmpty($pk))
			{
				continue;
			}
			$sqls += (("@DELETE FROM Sys_FrmLink WHERE MyPK='" . $pk) . "'");
		}
		$pks = $imgPKs->split("[@]", -1);
		foreach ($pks as $pk) 		{
			if ($DataType->IsNullOrEmpty($pk))
			{
				continue;
			}
			$sqls += (("@DELETE FROM Sys_FrmImg WHERE MyPK='" . $pk) . "'");
		}
		$pks = $attrPKs->split("[@]", -1);
		foreach ($pks as $pk) 		{
			if ($DataType->IsNullOrEmpty($pk))
			{
				continue;
			}
			if ($pk->equals("OID"))
			{
				continue;
			}
			$sqls += (((("@DELETE FROM Sys_MapAttr WHERE KeyOfEn='" . $pk) . "' AND FK_MapData='") . $fk_mapdata) . "'");
			$sqls += (((("@DELETE FROM Sys_FrmRB WHERE KeyOfEn='" . $pk) . "' AND FK_MapData='") . $fk_mapdata) . "'");
		}
		$pks = $dtlPKs->split("[@]", -1);
		foreach ($pks as $pk) 		{
			if ($DataType->IsNullOrEmpty($pk))
			{
				continue;
			}
			$dtl = MapDtl::constructor__();
			$dtl->setNo($pk);
			$dtl->RetrieveFromDBSources();
			$dtl->Delete();
		}
		$pks = $athMultis->split("[@]", -1);
		foreach ($pks as $pk) 		{
			if ($DataType->IsNullOrEmpty($pk))
			{
				continue;
			}
			$sqls += (((("@DELETE FROM Sys_FrmAttachment WHERE NoOfObj='" . $pk) . "' AND FK_MapData='") . $fk_mapdata) . "'");
		}
		$pks = $athImgs->split("[@]", -1);
		foreach ($pks as $pk) 		{
			if ($DataType->IsNullOrEmpty($pk))
			{
				continue;
			}
			$sqls += (((("@DELETE FROM Sys_FrmImgAth WHERE CtrlID='" . $pk) . "' AND FK_MapData='") . $fk_mapdata) . "'");
		}
		DBAccess->RunSQLs($sqls);
		$mymd = MapData::constructor__String($fk_mapdata);
		$mymd->RepairMap();
		SystemConfig->DoClearCash();
	}
	public static function CopyFrm ($srcFrmID, $copyFrmID, $copyFrmName, $fk_frmTree) // [String srcFrmID, String copyFrmID, String copyFrmName, String fk_frmTree]
	{
		$mymd = MapData::constructor__();
		$mymd->setNo($copyFrmID);
		if (($mymd->RetrieveFromDBSources() == 1))
		{
			throw new \RuntimeException((((("@目标表单ID:" . $copyFrmID) . "已经存在，位�?:") . $mymd->getFK_FormTreeText()) . "目录�?."));
		}
			/* match: String */
		$ds = CCFormAPI->GenerHisDataSet_String($srcFrmID);
		CCFormAPI::ImpFrmTemplate($copyFrmID, $ds,  FALSE );
		$md = MapData::constructor__String($copyFrmID);
		if (($md->getHisFrmType() == FrmType::$ExcelFrm))
		{
			$srcFile = (((SystemConfig::getPathOfDataUser() . "FrmOfficeTemplate/") . $srcFrmID) . ".xls");
			$toFile = (((SystemConfig::getPathOfDataUser() . "FrmOfficeTemplate/") . $copyFrmID) . ".xls");
			if (((new File($srcFile))->isFile() ==  TRUE ))
			{
				if (((new File($toFile))->isFile() ==  FALSE ))
				{
					$Files->copy($Paths->get($srcFile), $Paths->get($toFile), $StandardCopyOption->COPY_ATTRIBUTES);
				}
			}
			$srcFile = (((SystemConfig::getPathOfDataUser() . "FrmOfficeTemplate/") . $srcFrmID) . ".xlsx");
			$toFile = (((SystemConfig::getPathOfDataUser() . "FrmOfficeTemplate/") . $copyFrmID) . ".xlsx");
			if (((new File($srcFile))->isFile() ==  TRUE ))
			{
				if (((new File($toFile))->isFile() ==  FALSE ))
				{
					$Files->copy($Paths->get($srcFile), $Paths->get($toFile), $StandardCopyOption->COPY_ATTRIBUTES);
				}
			}
		}
		$md->Retrieve();
		$md->setFK_FormTree($fk_frmTree);
		$md->setFK_FrmSort($fk_frmTree);
		$md->setName($copyFrmName);
		$md->Update();
		return "表单复制成功,您需要重新登录，或�?�刷新才能看到�??";
	}
	public static function ImpFrmTemplate ($toFrmID, $fromds, $isSetReadonly) // [String toFrmID, DataSet fromds, boolean isSetReadonly]
	{
			/* match: String_DataSet */
		MapData->ImpMapData_String_DataSet($toFrmID, $fromds);
	}
	public static function AfterFrmEditAction ($frmID) // [String frmID]
	{
		CashFrmTemplate->Remove($frmID);
		$mapdata = MapData::constructor__String($frmID);
		$mapdata->CleanObject();
		return ;
	}
	public static function GenerHisDataSet_String ($frmID) // [String frmID]
	{
			/* match: String_String */
		return CCFormAPI->GenerHisDataSet_String_String($frmID, NULL);
	}
	public static function GenerHisDataSet_String_String ($frmID, $frmName) // [String frmID, String frmName]
	{
		$dsFrm =CashFrmTemplate->GetFrmDataSetModel($frmID);
		if (($dsFrm != NULL))
		{
			return $dsFrm;
		}
		$ds = new DataSet();
		$md = MapData::constructor__String($frmID);
		if ((($DataType->IsNullOrEmpty($md->getName()) ==  TRUE ) . ($frmName . NULL)))
		{
			$md->setName($frmName);
		}
		$Sys_MapData = $md->ToDataTableField("Sys_MapData");
		$ds->Tables->add($Sys_MapData);
		$Sys_GroupField = $md->getGroupFields()->ToDataTableField("Sys_GroupField");
		$ds->Tables->add($Sys_GroupField);
		$Sys_MapDtl = $md->getOrigMapDtls()->ToDataTableField("Sys_MapDtl");
		$ds->Tables->add($Sys_MapDtl);
		$Sys_Menu = $md->getSysEnums()->ToDataTableField("Sys_Enum");
		$ds->Tables->add($Sys_Menu);
		$Sys_MapAttr = $md->getMapAttrs()->ToDataTableField("Sys_MapAttr");
		$ds->Tables->add($Sys_MapAttr);
		$Sys_MapExt = $md->getMapExts()->ToDataTableField("Sys_MapExt");
		$ds->Tables->add($Sys_MapExt);
		$Sys_FrmLine = $md->getFrmLines()->ToDataTableField("Sys_FrmLine");
		$ds->Tables->add($Sys_FrmLine);
		$Sys_FrmLink = $md->getFrmLinks()->ToDataTableField("Sys_FrmLink");
		$ds->Tables->add($Sys_FrmLink);
		$Sys_FrmBtn = $md->getFrmBtns()->ToDataTableField("Sys_FrmBtn");
		$ds->Tables->add($Sys_FrmBtn);
		$Sys_FrmLab = $md->getFrmLabs()->ToDataTableField("Sys_FrmLab");
		$ds->Tables->add($Sys_FrmLab);
		$Sys_FrmImg = $md->getFrmImgs()->ToDataTableField("Sys_FrmImg");
		$ds->Tables->add($Sys_FrmImg);
		$Sys_FrmRB = $md->getFrmRBs()->ToDataTableField("Sys_FrmRB");
		$ds->Tables->add($Sys_FrmRB);
		$Sys_FrmEle = $md->getFrmEles()->ToDataTableField("Sys_FrmEle");
		$ds->Tables->add($Sys_FrmEle);
		$Sys_MapFrame = $md->getMapFrames()->ToDataTableField("Sys_MapFrame");
		$ds->Tables->add($Sys_MapFrame);
		$Sys_FrmAttachment = $md->getFrmAttachments()->ToDataTableField("Sys_FrmAttachment");
		$ds->Tables->add($Sys_FrmAttachment);
		$Sys_FrmImgAth = $md->getFrmImgAths()->ToDataTableField("Sys_FrmImgAth");
		$ds->Tables->add($Sys_FrmImgAth);
		$Sys_FrmImgAthDB = $md->getFrmImgAthDB()->ToDataTableField("Sys_FrmImgAthDB");
		$ds->Tables->add($Sys_FrmImgAthDB);
		CashFrmTemplate->Put($frmID, $ds);
		return $ds;
	}
	public static function GenerHisDataSet_AllEleInfo ($fk_mapdata) // [String fk_mapdata]
	{
		$md = MapData::constructor__String($fk_mapdata);
		$frmIDs = (("'" . $fk_mapdata) . "'");
		$mdtls = MapDtls::constructor__String($md->getNo());
		foreach ($mdtls->ToJavaList() as $item) 		{
			$frmIDs += ((",'" . $item->getNo()) . "'");
		}
		$ds = new DataSet();
		$Sys_MapData = $md->ToDataTableField("Sys_MapData");
		$ds->Tables->add($Sys_MapData);
		$gfs = GroupFields::constructor__();
		$gfs->RetrieveIn(GroupFieldAttr::$FrmID, $frmIDs);
		$Sys_GroupField = $gfs->ToDataTableField("Sys_GroupField");
		$ds->Tables->add($Sys_GroupField);
		$Sys_MapDtl = $md->getOrigMapDtls()->ToDataTableField("Sys_MapDtl");
		$ds->Tables->add($Sys_MapDtl);
		$ses = SysEnums::constructor__();
		$ses->RetrieveInSQL(SysEnumAttr::$EnumKey, (("SELECT UIBindKey FROM Sys_MapAttr WHERE FK_MapData IN (" . $frmIDs) . ") "));
		$Sys_Menu = $ses->ToDataTableField("Sys_Enum");
		$ds->Tables->add($Sys_Menu);
		$attrs = MapAttrs::constructor__();
		$attrs->RetrieveIn(MapAttrAttr::$FK_MapData, $frmIDs);
		$Sys_MapAttr = $attrs->ToDataTableField("Sys_MapAttr");
		$ds->Tables->add($Sys_MapAttr);
		$exts = MapExts::constructor__();
		$exts->RetrieveIn(MapAttrAttr::$FK_MapData, $frmIDs);
		$Sys_MapExt = $exts->ToDataTableField("Sys_MapExt");
		$ds->Tables->add($Sys_MapExt);
		$Sys_FrmLine = $md->getFrmLines()->ToDataTableField("Sys_FrmLine");
		$ds->Tables->add($Sys_FrmLine);
		$Sys_FrmLink = $md->getFrmLinks()->ToDataTableField("Sys_FrmLink");
		$ds->Tables->add($Sys_FrmLink);
		$Sys_FrmBtn = $md->getFrmBtns()->ToDataTableField("Sys_FrmBtn");
		$ds->Tables->add($Sys_FrmBtn);
		$frmlabs = FrmLabs::constructor__();
		$frmlabs->RetrieveIn(MapAttrAttr::$FK_MapData, $frmIDs);
		$Sys_FrmLab = $frmlabs->ToDataTableField("Sys_FrmLab");
		$ds->Tables->add($Sys_FrmLab);
		$frmImgs = FrmImgs::constructor__();
		$frmImgs->RetrieveIn(MapAttrAttr::$FK_MapData, $frmIDs);
		$ds->Tables->add($frmImgs->ToDataTableField("Sys_FrmImg"));
		$Sys_FrmRB = $md->getFrmRBs()->ToDataTableField("Sys_FrmRB");
		$ds->Tables->add($Sys_FrmRB);
		$Sys_FrmEle = $md->getFrmEles()->ToDataTableField("Sys_FrmEle");
		$ds->Tables->add($Sys_FrmEle);
		$Sys_MapFrame = $md->getMapFrames()->ToDataTableField("Sys_MapFrame");
		$ds->Tables->add($Sys_MapFrame);
		$Sys_FrmAttachment = $md->getFrmAttachments()->ToDataTableField("Sys_FrmAttachment");
		$ds->Tables->add($Sys_FrmAttachment);
		$Sys_FrmImgAth = $md->getFrmImgAths()->ToDataTableField("Sys_FrmImgAth");
		$ds->Tables->add($Sys_FrmImgAth);
		return $ds;
	}
	public static function GenerHisDataSet_AllEleInfo2017_String ($fk_mapdata) // [String fk_mapdata]
	{
			/* match: String_b */
		return CCFormAPI->GenerHisDataSet_AllEleInfo2017_String_b($fk_mapdata,  FALSE );
	}
	public static function GenerHisDataSet_AllEleInfo2017_String_b ($fk_mapdata, $isCheckFrmType) // [String fk_mapdata, boolean isCheckFrmType]
	{
		$md = MapData::constructor__String($fk_mapdata);
		$sql = "SELECT * FROM Sys_MapDtl WHERE FK_MapData ='{0}'";
		$sql = $String->format($sql, $fk_mapdata);
		$dtMapDtl = DBAccess->RunSQLReturnTable($sql);
		$dtMapDtl->TableName = "Sys_MapDtl";
		$ids = $String->format("'%1$s'", $fk_mapdata);
		foreach ($dtMapDtl->Rows as $dr) 		{
			$ids += ((",'" . $dr->get("No")) . "'");
		}
		$sqls = "";
		$listNames = [];// 
		$listNames->add("Sys_GroupField");
		$sql = (("SELECT * FROM Sys_GroupField WHERE  FrmID IN (" . $ids) . ")");
		$sqls += $sql;
		$listNames->add("Sys_Enum");
		$sql = (("@SELECT * FROM Sys_Enum WHERE EnumKey IN ( SELECT UIBindKey FROM Sys_MapAttr WHERE FK_MapData IN (" . $ids) . ") ) order By EnumKey,IntKey");
		$sqls += $sql;
		$nodeIDstr = $fk_mapdata->replace("ND", "");
		if ($DataType->IsNumStr($nodeIDstr))
		{
			$listNames->add("WF_Node");
			$sql = (("@SELECT * FROM WF_Node WHERE NodeID=" . $nodeIDstr) . " AND  ( FWCSta >0  OR SFSta >0 )");
			$sqls += $sql;
		}
		$where = ((" FK_MapData IN (" . $ids) . ")");
		$listNames->add("Sys_MapData");
		$sql = (("@SELECT * FROM Sys_MapData WHERE No='" . $fk_mapdata) . "'");
		$sqls += $sql;
		$listNames->add("Sys_MapAttr");
		$sql = (("@SELECT * FROM Sys_MapAttr WHERE " . $where) . " AND KeyOfEn NOT IN('WFState') ORDER BY FK_MapData, IDX  ");
		$sqls += $sql;
		$listNames->add("Sys_MapExt");
		$sql = ("@SELECT * FROM Sys_MapExt WHERE " . $where);
		$sqls += $sql;
		$listNames->add("Sys_FrmLine");
		$sql = ("@SELECT * FROM Sys_FrmLine WHERE " . $where);
		$sqls += $sql;
		$listNames->add("Sys_FrmLink");
		$sql = ("@SELECT * FROM Sys_FrmLink WHERE " . $where);
		$sqls += $sql;
		$listNames->add("Sys_FrmBtn");
		$sql = ("@SELECT * FROM Sys_FrmBtn WHERE " . $where);
		$sqls += $sql;
		$listNames->add("Sys_FrmImg");
		$sql = ("@SELECT * FROM Sys_FrmImg WHERE " . $where);
		$sqls += $sql;
		$listNames->add("Sys_FrmLab");
		$sql = ("@SELECT * FROM Sys_FrmLab WHERE " . $where);
		$sqls += $sql;
		$listNames->add("Sys_FrmRB");
		$sql = ("@SELECT * FROM Sys_FrmRB WHERE " . $where);
		$sqls += $sql;
		$listNames->add("Sys_FrmEle");
		$sql = ("@SELECT * FROM Sys_FrmEle WHERE " . $where);
		$sqls += $sql;
		$listNames->add("Sys_MapFrame");
		$sql = ("@SELECT * FROM Sys_MapFrame WHERE " . $where);
		$sqls += $sql;
		$listNames->add("Sys_FrmAttachment");
		$sql = ((("@SELECT * " . " FROM Sys_FrmAttachment WHERE ") . $where) . "");
		$sqls += $sql;
		$listNames->add("Sys_FrmImgAth");
		$sql = ("@SELECT * FROM Sys_FrmImgAth WHERE " . $where);
		$sqls += $sql;
		$strs = $sqls->split("[@]", -1);
		$ds = new DataSet();
		if ((($strs != NULL) && (count($strs) /*from: strs.length*/ == $listNames->size())))
		{
			for ($i = 0; ($i < $listNames->size()); ++$i) 
			{
				$s = $strs[$i];
				if ($DataType->IsNullOrEmpty($s))
				{
					continue;
				}
				$dt =DBAccess->RunSQLReturnTable($s);
				$dt->TableName = $listNames->get($i);
				$ds->Tables->add($dt);
			}
		}
		foreach ($ds->Tables as $item) 		{
			if (($item->TableName->equals("Sys_MapAttr") && ($item->Rows->size() == 0)))
			{
				$md->RepairMap();
			}
		}
		$ds->Tables->add($dtMapDtl);
		return $ds;
	}
	public static function SaveEnum_String_String_String_b ($enumKey, $enumLab, $cfg, $isNew) // [String enumKey, String enumLab, String cfg, boolean isNew]
	{
			/* match: String_String_String_b_String */
		return CCFormAPI->SaveEnum_String_String_String_b_String($enumKey, $enumLab, $cfg, $isNew, "CH");
	}
	public static function SaveEnum_String_String_String_b_String ($enumKey, $enumLab, $cfg, $isNew, $lang) // [String enumKey, String enumLab, String cfg, boolean isNew, String lang]
	{
		$sem = SysEnumMain::constructor__();
		$sem->setNo($enumKey);
		$dataCount = $sem->RetrieveFromDBSources();
		if ((($dataCount > 0) && $isNew))
		{
			return (("err@已存在枚�?" . $enumKey) . ",请修改枚举名�?");
		}
		if (($dataCount == 0))
		{
			$sem->setName($enumLab);
			$sem->setCfgVal($cfg);
			$sem->setLang($lang);
			$sem->DirectInsert();
		}
		else
		{
			$sem->setName($enumLab);
			$sem->setCfgVal($cfg);
			$sem->setLang($lang);
			$sem->Update();
		}
		$strs = $cfg->split("[@]", -1);
		foreach ($strs as $str) 		{
			if ($DataType->IsNullOrEmpty($str))
			{
				continue;
			}
			$kvs = $str->split("[=]", -1);
			$se = SysEnum::constructor__();
			$se->setEnumKey($enumKey);
			$se->setLang($lang);
			$se->setIntKey($Integer->parseInt($kvs[0]));
			$kvsValues = array();
			for ($i = 0; ($i < count($kvsValues) /*from: kvsValues.length*/); ++$i) 
			{
				$kvsValues[$i] = $kvs[($i + 1)];
			}
			$se->setLab($StringHelper->join("=", $kvsValues));
			$se->setMyPK((((($se->getEnumKey() . "_") . $se->getLang()) . "_") . $se->getIntKey()));
			$se->Save();
		}
		return "保存成功.";
	}
	public static function ParseStringToPinyinField_String_b ($name, $isQuanPin) // [String name, boolean isQuanPin]
	{
		if ((DataType->IsNullOrEmpty($name) ==  TRUE ))
		{
			return "";
		}
		$s = "";
		try 
		{
			if (($isQuanPin ==  TRUE ))
			{
				$s =DataType->ParseStringToPinyin($name);
				if (($s->length() > 15))
				{
					$s =DataType->ParseStringToPinyinJianXie($name);
				}
			}
			else
			{
				$s =DataType->ParseStringToPinyinJianXie($name);
			}
			$s = $s->trim()->replace(" ", "");
			$s = $s->trim()->replace(" ", "");
			$s = $s->replace(",", "")->replace(".", "")->replace("�?", "")->replace("�?", "")->replace("!", "");
			$s = $s->replace("*", "")->replace("@", "")->replace("#", "")->replace("~", "")->replace("|", "");
			$s = $s->replace("$", "")->replace("%", "")->replace("&", "")->replace("�?", "")->replace("�?", "")->replace("�?", "")->replace("�?", "");
			$s = $s->replace("(", "")->replace(")", "")->replace("[", "")->replace("]", "")->replace("{", "")->replace("}", "")->replace("/", "");
			if (($s->length() > 0))
			{
				$headStr = $s->substring(0, 1);
				if (($DataType->IsNumStr($headStr) ==  TRUE ))
				{
					$s = ("F" . $s);
				}
			}
			$s = $s->replace(" ", "");
			$s = $s->replace(".", "");
			return $s;
		}
		catch (\RuntimeException $ex)
		{
			throw new \RuntimeException($ex->getMessage());
		}
	}
	public static function ParseStringToPinyinField_String_b_b_I ($name, $isQuanPin, $removeSpecialSymbols, $maxLen) // [String name, boolean isQuanPin, boolean removeSpecialSymbols, int maxLen]
	{
		if ((DataType->IsNullOrEmpty($name) ==  TRUE ))
		{
			return "";
		}
		$s = "";
		if ($removeSpecialSymbols)
		{
			$name = $DataType->ParseStringForName($name, $maxLen);
		}
		try 
		{
			if (($isQuanPin ==  TRUE ))
			{
				$s =DataType->ParseStringToPinyin($name);
			}
			else
			{
				$s =DataType->ParseStringToPinyinJianXie($name);
			}
			if ((($maxLen > 0) && ($s->length() > $maxLen)))
			{
				$s = $s->substring(0, $maxLen);
			}
			if (($s->length() > 0))
			{
				$headStr = $s->substring(0, 1);
				if (($DataType->IsNumStr($headStr) ==  TRUE ))
				{
					$s = ("F" . (( (($s->length() > ($maxLen - 1))) ? $s->substring(0, ($maxLen - 1)) : $s )));
				}
			}
			return $s;
		}
		catch (\RuntimeException $ex)
		{
			throw new \RuntimeException($ex->getMessage());
		}
	}
	public static function ChinaMulTonesToPinYin ($charT) // [String charT]
	{
		try 
		{
			$mulChs = ChMulToneXmls::constructor__();
			$mulChs->RetrieveAll();
			foreach ($mulChs->ToJavaList() as $en) 			{
				if ($en->getNo()->equals($charT))
				{
					return $en->getName();
				}
			}
		}
		catch (\RuntimeException $ex)
		{
			throw new \RuntimeException($ex->getMessage());
		}
		return NULL;
	}
	public static function DB_SFTableList ($pageNumber, $pageSize) // [int pageNumber, int pageSize]
	{
		$sftables = SFTables::constructor__();
		$obj = new QueryObject($sftables);
		$RowCount = $obj->GetCount();
		$obj->DoQuery(SysEnumMainAttr::$No, $pageSize, $pageNumber);
		return $BP->Tools->Json->ToJson($sftables->ToDataTableField());
	}
	public static function DB_Hiddenfielddata ($fk_mapdata) // [String fk_mapdata]
	{
		$mapAttrs = MapAttrs::constructor__();
		$obj = new QueryObject($mapAttrs);
		$obj->AddWhere(MapAttrAttr::$FK_MapData, $fk_mapdata);
		$obj->addAnd();
		$obj->AddWhere(MapAttrAttr::$UIVisible, "0");
		$obj->addAnd();
		$obj->AddWhere(MapAttrAttr::$EditType, "0");
		$obj->DoQuery();
		return $mapAttrs->ToJson();
	}
}
?>
